package com.singzi.leetcode.N100;

import java.util.ArrayList;
import java.util.List;

public class T0077 {
    public static void main(String[] args) {
        Solution0077 solution0077  =new Solution0077();
        System.out.println(solution0077.combine(4, 2));

    }
}
class Solution0077{

    private List<List<Integer>>list = new ArrayList<>();
    private List<Integer> temp = new ArrayList<>();
    private void traceBack(int n, int k, int index){
        if(temp.size()==k){
            System.out.println("temp:"+temp);
            list.add(new ArrayList<>(temp));
            System.out.println("list"+list);
            return;
        }
        for(int i = index; i<=n; i++){
            temp.add(i);
            traceBack(n, k, i+1);
            temp.remove(temp.size()-1);

        }
    }
    public List<List<Integer>> combine(int n, int k){

        traceBack(n, k, 1);
        return list;
    }
}
